<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('交易规则')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-tradeset-edit" th:object="${sysTradeset}">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">交易币名称：</label>
                <div class="col-sm-8">
                    <input name="glodname" th:field="*{glodname}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">交易币单位：</label>
                <div class="col-sm-8">
                    <input name="glodunit" th:field="*{glodunit}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">交易规则：</label>
                <div class="col-sm-8">
                    <input type="checkbox" id="toauth" th:checked="${sysTradeset.toauth == 1 ? true : false}">用户阅读/下载扣除的金额给上传者
                </div>
                <div class="col-sm-8">
                    <input type="checkbox" id="toauth2" th:checked="${sysTradeset.toauth2 == 1 ? true : false}">匿名用户扫码付费的金额也给上传者
                </div>
            </div>
        </div>

        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">交易税率：</label>
                <div class="col-sm-8">
                    <input name="rate" th:field="*{rate}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">免费时限：</label>
                <div class="col-sm-8">
                    <input name="paydue" th:field="*{paydue}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12" style="display: none">
            <div class="form-group">
                <label class="col-sm-3 control-label">${comment}：</label>
                <div class="col-sm-8">
                    <input name="rewardtop" th:field="*{rewardtop}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12" style="display: none">
            <div class="form-group">
                <label class="col-sm-3 control-label">${comment}：</label>
                <div class="col-sm-8">
                    <input name="backrate" th:field="*{backrate}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">最低充值金额：</label>
                <div class="col-sm-8">
                    <input name="glodin" th:field="*{glodin}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">最低提现金额：</label>
                <div class="col-sm-8">
                    <input name="glodout" th:field="*{glodout}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">交易币兑换比例：</label>
                <div class="col-sm-8">
                    <input name="glodrate" th:field="*{glodrate}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">最低兑换积分：</label>
                <div class="col-sm-8">
                    <input name="pointout" th:field="*{pointout}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">积分兑换比例：</label>
                <div class="col-sm-8">
                    <input name="pointrate" th:field="*{pointrate}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/tradeset";
    $("#form-tradeset-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-tradeset-edit').serializeArray();
            var toauth = $("input[id='toauth']").is(':checked') == true ? 1 : 0;
            var toauth2 = $("input[id='toauth2']").is(':checked') == true ? 1 : 0;
            data.push({"name": "toauth", "value": toauth});
            data.push({"name": "toauth2", "value": toauth2});
            $.operate.save(prefix + "/edit", data,function(result) {
                layer.msg(result.msg, {
                        icon: $.modal.icon(0),
                        time: 500,
                        shade: [0.1, '#8F8F8F']
                    });
            });
        }
    }
</script>
</body>
</html>